//
//  HDUserInfoViewController.swift
//  HuaDaoPeifu
//
//  Created by Erickson on 16/4/7.
//  Copyright © 2016年 paiyipai. All rights reserved.
//

import UIKit

class HDUserInfoViewController: UIViewController {

    let userInfoTableView = UITableView(frame: CGRectZero, style: .Grouped)
    
    let systemPhoto = PYPSystemCameraPhotoControl()
//    override func viewWillAppear(animated: Bool) {
//        navigationController?.navigationBarHidden = false
//    }
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = UIColor.whiteColor()
        title = "个人信息"
        setupViews()
    }
    func setupViews() {
        view.addSubview(userInfoTableView)
        userInfoTableView.dataSource = self
        userInfoTableView.delegate = self

        userInfoTableView.snp_makeConstraints { (make) in
            make.edges.equalTo(view)
        }
    }
   
    
    
}


extension HDUserInfoViewController : UITableViewDelegate {
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        print("sfsafds")
        if indexPath.row == 0 {
            systemPhoto.editAvatar(self)
            
          return
        }
        //银行信息
        navigationController?.pushViewController(HDBankInfoViewController(), animated: true)
        
    }
}

extension HDUserInfoViewController: PYPSystemCameraPhotoControlDelegate {
    func didFinishPickingMediaWithInfo(info: [String : AnyObject]) {
        let image = info[UIImagePickerControllerEditedImage] as? UIImage
        print(image)
    }
}

extension HDUserInfoViewController: UITableViewDataSource {
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 8
    }
    
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        
        var cell = tableView.dequeueReusableCellWithIdentifier("userCell")
        
        if cell == nil {
            cell = UITableViewCell(style: .Value1, reuseIdentifier: "userCell")

        }
        cell!.accessoryType = .DisclosureIndicator
        cell!.textLabel?.text = "\(indexPath.row)"
        cell?.detailTextLabel?.text = "hahahha"
        return cell!
    }
}